<?php

/**
 * Breadcrumb generator helper
 *
 * @package Rapide_View
 * @subpackage Rapide_View_Html
 */
class Rapide_View_Helper_Breadcrumb extends Rapide_View_Helper
{
	/**
	 * Generate breadcrumb
	 *
	 * @param string $sDelimiter
	 * @param string $sStart starting element
	 * @return string
	 */
	public function execute($sDelimiter = ' - ', $sStart = null)
	{
		$aBreadcrumbs = Rapide_Util_Breadcrumb::getInstance()->getArray();

		if(!empty($sStart))
		{
			$aStart = array
			(
				$sStart,
				Rapide_Controller_Front::getInstance()->getRouter()->url()
			);

			array_unshift($aBreadcrumbs, $aStart);
		}

		$sBreadcrumb = '';

		foreach($aBreadcrumbs as $aEntry)
		{
			$sBreadcrumb .= '<a href="' . $aEntry[1] . '">' . $aEntry[0] . '</a> ' . $sDelimiter;
		}

		return substr($sBreadcrumb, 0, -1 * strlen($sDelimiter));
	}
}

?>